class baikuai extends eui.Component implements eui.UIComponent{

    private bg1:eui.Rect;//白块
    private bg2:eui.Rect;
    private bg3:eui.Rect;
    private bg4:eui.Rect;
    private bg5:eui.Rect;
    private bg6:eui.Rect;
    private bg11:eui.Rect;
    private bg22:eui.Rect;
    private bg33:eui.Rect;
    private bg44:eui.Rect;
    private bg55:eui.Rect;
    private bg66:eui.Rect;
    private bg111:eui.Rect;
    private bg222:eui.Rect;
    private bg333:eui.Rect;
    private bg444:eui.Rect;
    private bg555:eui.Rect;
    private bg666:eui.Rect;
    private bg1111:eui.Rect;
    private bg2222:eui.Rect;
    private bg3333:eui.Rect;
    private bg4444:eui.Rect;
    private bg5555:eui.Rect;
    private bg6666:eui.Rect;
    private musictime:number=0;
    private bgmusic:egret.Sound;
    private btnstosta:egret.Bitmap;
    private btnstostanum:number=0;
    private group1:eui.Rect[];
    private group2:eui.Rect[];
    private group3:eui.Rect[];
    private group4:eui.Rect[];
         private ctrmusic:egret.SoundChannel;
         private scorl:number=0;//分数
         private speed:number=6;//速度
         private cj:egret.TextField;//显示成绩的文本框
         private panel:nobk.scrolpanel;//计分板
         private updatetimer:egret.Timer=new egret.Timer(1);//定时器
         private maxscorl:number;
       public constructor(){
           super();
           this.btnstosta=this.createBitmapByName("start_png");
           this.btnstosta.x=580;
           this.btnstosta.y=0;
           this.btnstosta.touchEnabled=true;
           this.addChild(this.btnstosta);
           this.cj=new egret.TextField();
           this.cj.width=640;
           this.cj.text="得分:00  当前速度:00"
           this.cj.textAlign="center";
           this.cj.textColor=0x2dd5f9;
           this.addChild(this.cj);
           this.maxscorl=JSON.parse(localStorage.getItem("scrol"));
           this.bgmusic=new egret.Sound();
           this.bgmusic=RES.getRes("sakura_mp3");
           
        }
        protected childrenCreated():void
	{
    this.btnstosta.addEventListener(egret.TouchEvent.TOUCH_TAP,this.btnstatu,this);
    this.bg1.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg2.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg3.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg4.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg5.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg6.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg11.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg22.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg33.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg44.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg55.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg66.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg111.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg222.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg333.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg444.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg555.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg666.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg1111.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg2222.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg3333.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg4444.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg5555.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg6666.addEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.group1=[];
    this.group1.push(this.bg1,this.bg2,this.bg3,this.bg4,this.bg5,this.bg6)
    this.group2=[];
     this.group2.push(this.bg11,this.bg22,this.bg33,this.bg44,this.bg55,this.bg66)
    this.group3=[];
    this.group3.push(this.bg111,this.bg222,this.bg333,this.bg444,this.bg555,this.bg666)
    this.group4=[];
    this.group4.push(this.bg1111,this.bg2222,this.bg3333,this.bg4444,this.bg5555,this.bg6666)
	}
    public starttimer(){
         this.updatetimer.addEventListener(egret.TimerEvent.TIMER,this.updatebg,this);
         this.updatetimer.start();
        this.musicstart();
    }
    private btnstatu(){
        this.btnstostanum+=1
        if(this.btnstostanum%2!=0){
             this.updatetimer.stop();
             this.musictime=this.ctrmusic.position;
             this.musicstop();
        }else{
             this.updatetimer.reset();
             this.updatetimer.start();
             this.musicstart();
        }
    }
  public updatebg(){

     let a=Math.ceil(Math.random()*4)
     let b=Math.ceil(Math.random()*5)
     let c=Math.ceil(Math.random()*4)
     let d=Math.ceil(Math.random()*5)
     if(a==1){   //左边第一排开始
         if(this.bg6.y==(-229.09+this.speed)){
         this.bg6.fillColor=0x000000;
         }
         else if(this.bg1.y==(-229.09+this.speed)){
         this.bg1.fillColor=0x000000;
       }
         else if(this.bg2.y==(-229.09+this.speed)){
         this.bg2.fillColor=0x000000;
        }
         else if(this.bg3.y==(-229.09+this.speed)){
         this.bg3.fillColor=0x000000;
       }
         else if(this.bg4.y==(-229.09+this.speed)){
         this.bg4.fillColor=0x000000;
        }
         else if(this.bg5.y==(-229.09+this.speed)){
         this.bg5.fillColor=0x000000;
       }
    } else{
          if(this.bg6.y==(-229.09+this.speed)){
         this.bg6.fillColor=0xffffff;
         }
         else if(this.bg1.y==(-229.09+this.speed)){
         this.bg1.fillColor=0xffffff;
       }
         else if(this.bg2.y==(-229.09+this.speed)){
         this.bg2.fillColor=0xffffff;
        }
         else if(this.bg3.y==(-229.09+this.speed)){
         this.bg3.fillColor=0xffffff;
       }
       else if(this.bg4.y==(-229.09+this.speed)){
         this.bg4.fillColor=0xffffff;
        }
        else if(this.bg5.y==(-229.09+this.speed)){
         this.bg5.fillColor=0xffffff;
       }
 }//左边结束
  if(b==1){   //左边第二排开始
       if(this.bg66.y==(-229.09+this.speed)){
         this.bg66.fillColor=0x000000;
         }
         else if(this.bg11.y==(-229.09+this.speed)){
         this.bg11.fillColor=0x000000;
       }
         else if(this.bg22.y==(-229.09+this.speed)){
         this.bg22.fillColor=0x000000;
        }
         else if(this.bg33.y==(-229.09+this.speed)){
         this.bg33.fillColor=0x000000;
       }
         else if(this.bg44.y==(-229.09+this.speed)){
         this.bg44.fillColor=0x000000;
        }
         else if(this.bg55.y==(-229.09+this.speed)){
         this.bg55.fillColor=0x000000;
        }
    } else{
          if(this.bg66.y==(-229.09+this.speed)){
         this.bg66.fillColor=0xffffff;
         }
         else if(this.bg11.y==(-229.09+this.speed)){
         this.bg11.fillColor=0xffffff;
       }
         else if(this.bg22.y==(-229.09+this.speed)){
         this.bg22.fillColor=0xffffff;
        }
         else if(this.bg33.y==(-229.09+this.speed)){
         this.bg33.fillColor=0xffffff;
       }
       else if(this.bg44.y==(-229.09+this.speed)){
         this.bg44.fillColor=0xffffff;
        }
        else if(this.bg55.y==(-229.09+this.speed)){
         this.bg55.fillColor=0xffffff;
       }
  }
  //第三排开始
   if(c==1){  
       if(this.bg666.y==(-229.09+this.speed)){
         this.bg666.fillColor=0x000000;
         }
         else if(this.bg111.y==(-229.09+this.speed)){
         this.bg111.fillColor=0x000000;
       }
         else if(this.bg222.y==(-229.09+this.speed)){
         this.bg222.fillColor=0x000000;
        }
         else if(this.bg333.y==(-229.09+this.speed)){
         this.bg333.fillColor=0x000000;
       }
         else if(this.bg444.y==(-229.09+this.speed)){
         this.bg444.fillColor=0x000000;
        }
         else if(this.bg555.y==(-229.09+this.speed)){
         this.bg555.fillColor=0x000000;
        }
    } else{
          if(this.bg666.y==(-229.09+this.speed)){
         this.bg666.fillColor=0xffffff;
         }
         else if(this.bg111.y==(-229.09+this.speed)){
         this.bg111.fillColor=0xffffff;
       }
         else if(this.bg222.y==(-229.09+this.speed)){
         this.bg222.fillColor=0xffffff;
        }
         else if(this.bg333.y==(-229.09+this.speed)){
         this.bg333.fillColor=0xffffff;
       }
       else if(this.bg444.y==(-229.09+this.speed)){
         this.bg444.fillColor=0xffffff;
        }
        else if(this.bg555.y==(-229.09+this.speed)){
         this.bg555.fillColor=0xffffff;
       }
  }
  //最后一排
  if(d==1){  
       if(this.bg6666.y==(-229.09+this.speed)){
         this.bg6666.fillColor=0x000000;
         }
         else if(this.bg1111.y==(-229.09+this.speed)){
         this.bg1111.fillColor=0x000000;
       }
         else if(this.bg2222.y==(-229.09+this.speed)){
         this.bg2222.fillColor=0x000000;
        }
         else if(this.bg3333.y==(-229.09+this.speed)){
         this.bg3333.fillColor=0x000000;
       }
         else if(this.bg4444.y==(-229.09+this.speed)){
         this.bg4444.fillColor=0x000000;
        }
         else if(this.bg5555.y==(-229.09+this.speed)){
         this.bg5555.fillColor=0x000000;
        }
    } else{
          if(this.bg6666.y==(-229.09+this.speed)){
         this.bg6666.fillColor=0xffffff;
         }
         else if(this.bg1111.y==(-229.09+this.speed)){
         this.bg1111.fillColor=0xffffff;
       }
         else if(this.bg2222.y==(-229.09+this.speed)){
         this.bg2222.fillColor=0xffffff;
        }
         else if(this.bg3333.y==(-229.09+this.speed)){
         this.bg3333.fillColor=0xffffff;
       }
       else if(this.bg4444.y==(-229.09+this.speed)){
         this.bg4444.fillColor=0xffffff;
        }
        else if(this.bg5555.y==(-229.09+this.speed)){
         this.bg5555.fillColor=0xffffff;
        }
  }
       //第一排重置初始位置
         if(this.bg1.y>=0&&this.bg1.y<=this.speed){
         this.bg6.y=(-229.09-this.speed)}
         if(this.bg2.y>=0&&this.bg2.y<=this.speed){
         this.bg1.y=(-229.09-this.speed)}
         if(this.bg3.y>=0&&this.bg3.y<=this.speed){
         this.bg2.y=(-229.09-this.speed)}
         if(this.bg4.y>=0&&this.bg4.y<=this.speed){
         this.bg3.y=(-229.09-this.speed)}
         if(this.bg5.y>=0&&this.bg5.y<=this.speed){
         this.bg4.y=(-229.09-this.speed)}
         if(this.bg6.y>=0&&this.bg6.y<=this.speed){
         this.bg5.y=(-229.09-this.speed)}
   //第二排重置初始位置
         if(this.bg11.y>=0&&this.bg11.y<=this.speed){
         this.bg66.y=(-229.09-this.speed)}
         if(this.bg22.y>=0&&this.bg22.y<=this.speed){
         this.bg11.y=(-229.09-this.speed)}
         if(this.bg33.y>=0&&this.bg33.y<=this.speed){
         this.bg22.y=(-229.09-this.speed)}
         if(this.bg44.y>=0&&this.bg44.y<=this.speed){
         this.bg33.y=(-229.09-this.speed)}
         if(this.bg55.y>=0&&this.bg55.y<=this.speed){
         this.bg44.y=(-229.09-this.speed)}
         if(this.bg66.y>=0&&this.bg66.y<=this.speed){
         this.bg55.y=(-229.09-this.speed)}
    //第三排
    if(this.bg111.y>=0&&this.bg111.y<=this.speed){
         this.bg666.y=(-229.09-this.speed)}
         if(this.bg222.y>=0&&this.bg222.y<=this.speed){
         this.bg111.y=(-229.09-this.speed)}
         if(this.bg333.y>=0&&this.bg333.y<=this.speed){
         this.bg222.y=(-229.09-this.speed)}
         if(this.bg444.y>=0&&this.bg444.y<=this.speed){
         this.bg333.y=(-229.09-this.speed)}
         if(this.bg555.y>=0&&this.bg555.y<=this.speed){
         this.bg444.y=(-229.09-this.speed)}
         if(this.bg666.y>=0&&this.bg666.y<=this.speed){
         this.bg555.y=(-229.09-this.speed)}
    //第四排
    if(this.bg1111.y>=0&&this.bg1111.y<=this.speed){
         this.bg6666.y=(-229.09-this.speed)}
         if(this.bg2222.y>=0&&this.bg2222.y<=this.speed){
         this.bg1111.y=(-229.09-this.speed)}
         if(this.bg3333.y>=0&&this.bg3333.y<=this.speed){
         this.bg2222.y=(-229.09-this.speed)}
         if(this.bg4444.y>=0&&this.bg4444.y<=this.speed){
         this.bg3333.y=(-229.09-this.speed)}
         if(this.bg5555.y>=0&&this.bg5555.y<=this.speed){
         this.bg4444.y=(-229.09-this.speed)}
         if(this.bg6666.y>=0&&this.bg6666.y<=this.speed){
         this.bg5555.y=(-229.09-this.speed)}
       //得分越高 速度越快
         //第一排移动
   for(let a=0;a<6;a++){
        this.group1[a].y+=this.speed;
        this.group2[a].y+=this.speed;
        this.group3[a].y+=this.speed;
        this.group4[a].y+=this.speed;
       
    }
    
    
    if(this.bg1.y+229.09>=1136&&this.bg1.fillColor==0x000000){this.gameover();}
    else if(this.bg2.y+229.09>=1136&&this.bg2.fillColor==0x000000){this.gameover();}
    else if(this.bg3.y+229.09>=1136&&this.bg3.fillColor==0x000000){this.gameover();}
    else if(this.bg4.y+229.09>=1136&&this.bg4.fillColor==0x000000){this.gameover();}
    else if(this.bg5.y+229.09>=1136&&this.bg5.fillColor==0x000000){this.gameover();}
    else if(this.bg6.y+229.09>=1136&&this.bg6.fillColor==0x000000){this.gameover();}
    else if(this.bg11.y+229.09>=1136&&this.bg11.fillColor==0x000000){this.gameover();}
    else if(this.bg22.y+229.09>=1136&&this.bg22.fillColor==0x000000){this.gameover();}
    else if(this.bg33.y+229.09>=1136&&this.bg33.fillColor==0x000000){this.gameover();}
    else if(this.bg44.y+229.09>=1136&&this.bg44.fillColor==0x000000){this.gameover();}
    else if(this.bg55.y+229.09>=1136&&this.bg55.fillColor==0x000000){this.gameover();}
    else if(this.bg66.y+229.09>=1136&&this.bg66.fillColor==0x000000){this.gameover();}
    else if(this.bg111.y+229.09>=1136&&this.bg111.fillColor==0x000000){this.gameover();}
    else if(this.bg222.y+229.09>=1136&&this.bg222.fillColor==0x000000){this.gameover();}
    else if(this.bg333.y+229.09>=1136&&this.bg333.fillColor==0x000000){this.gameover();}
    else if(this.bg444.y+229.09>=1136&&this.bg444.fillColor==0x000000){this.gameover();}
    else if(this.bg555.y+229.09>=1136&&this.bg555.fillColor==0x000000){this.gameover();}
    else if(this.bg666.y+229.09>=1136&&this.bg666.fillColor==0x000000){this.gameover();}
    else if(this.bg1111.y+229.09>=1136&&this.bg1111.fillColor==0x000000){this.gameover();}
    else if(this.bg2222.y+229.09>=1136&&this.bg2222.fillColor==0x000000){this.gameover();}
    else if(this.bg3333.y+229.09>=1136&&this.bg3333.fillColor==0x000000){this.gameover();}
    else if(this.bg4444.y+229.09>=1136&&this.bg4444.fillColor==0x000000){this.gameover();}
    else if(this.bg5555.y+229.09>=1136&&this.bg5555.fillColor==0x000000){this.gameover();}
    else if(this.bg6666.y+229.09>=1136&&this.bg6666.fillColor==0x000000){this.gameover();}
    
     //console.log(a);
  } 
  private chengji(e:egret.TouchEvent){
       if(e.target==this.bg1){
           if(this.bg1.fillColor==0x000000){
               this.bg1.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
        if(e.target==this.bg2){
           if(this.bg2.fillColor==0x000000){
               this.bg2.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
        if(e.target==this.bg3){
           if(this.bg3.fillColor==0x000000){
               this.bg3.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
        if(e.target==this.bg4){
           if(this.bg4.fillColor==0x000000){
               this.bg4.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
        if(e.target==this.bg5){
           if(this.bg5.fillColor==0x000000){
               this.bg5.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg6){
           if(this.bg6.fillColor==0x000000){
               this.bg6.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }

       //第二排
       if(e.target==this.bg66){
           if(this.bg66.fillColor==0x000000){
               this.bg66.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg55){
           if(this.bg55.fillColor==0x000000){
               this.bg55.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg44){
           if(this.bg44.fillColor==0x000000){
               this.bg44.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg33){
           if(this.bg33.fillColor==0x000000){
               this.bg33.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg22){
           if(this.bg22.fillColor==0x000000){
               this.bg22.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg11){
           if(this.bg11.fillColor==0x000000){
               this.bg11.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       //第三排
      if(e.target==this.bg666){
           if(this.bg666.fillColor==0x000000){
               this.bg666.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg555){
           if(this.bg555.fillColor==0x000000){
               this.bg555.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg444){
           if(this.bg444.fillColor==0x000000){
               this.bg444.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg333){
           if(this.bg333.fillColor==0x000000){
               this.bg333.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg222){
           if(this.bg222.fillColor==0x000000){
               this.bg222.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg111){
           if(this.bg111.fillColor==0x000000){
               this.bg111.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       //第四排
      if(e.target==this.bg6666){
           if(this.bg6666.fillColor==0x000000){
               this.bg6666.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg5555){
           if(this.bg5555.fillColor==0x000000){
               this.bg5555.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg4444){
           if(this.bg4444.fillColor==0x000000){
               this.bg4444.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg3333){
           if(this.bg3333.fillColor==0x000000){
               this.bg3333.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg2222){
           if(this.bg2222.fillColor==0x000000){
               this.bg2222.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }
       if(e.target==this.bg1111){
           if(this.bg1111.fillColor==0x000000){
               this.bg1111.fillColor=0xffffff;
               this.scorl+=1;
           }else{this.gameover();}
       }  


       if(this.scorl>=11&&this.scorl<=30)this.speed=8;
       if(this.scorl>=31&&this.scorl<=60)this.speed=10;
       if(this.scorl>=61&&this.scorl<=90)this.speed=12;
       if(this.scorl>=91&&this.scorl<=120)this.speed=14;
       if(this.scorl>=121)this.speed=20;
    this.cj.text="得分:"+this.scorl+"  当前速度:"+this.speed;
}
private gameover(){
    this.musicstop();
    this.bg1.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg2.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg3.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg4.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg5.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg6.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg11.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg22.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg33.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg44.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg55.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg66.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg111.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg222.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg333.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg444.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg555.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg666.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg1111.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg2222.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg3333.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg4444.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg5555.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg6666.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.chengji,this);
    this.bg1.visible=false;
    this.bg2.visible=false;
    this.bg3.visible=false;
    this.bg4.visible=false;
    this.bg5.visible=false;
    this.bg6.visible=false;
    this.bg11.visible=false;
    this.bg22.visible=false;
    this.bg33.visible=false;
    this.bg44.visible=false;
    this.bg55.visible=false;
    this.bg66.visible=false;
    this.bg111.visible=false;
    this.bg222.visible=false;
    this.bg333.visible=false;
    this.bg444.visible=false;
    this.bg555.visible=false;
    this.bg666.visible=false;
    this.bg1111.visible=false;
    this.bg2222.visible=false;
    this.bg3333.visible=false;
    this.bg4444.visible=false;
    this.bg5555.visible=false;
    this.bg6666.visible=false;
    this.removeChild(this.cj);
    this.panel=new nobk.scrolpanel();
    this.addChild(this.panel);
    this.updatetimer.stop();
    if(this.scorl>this.maxscorl)
     {this.maxscorl=this.scorl;
    let aaa=JSON.stringify(this.maxscorl);
    localStorage.setItem("scrol",aaa);
     }

    this.panel.gameend(this.scorl);
}
  private musicstart(){
      this.ctrmusic=this.bgmusic.play(this.musictime);
  }
  private musicstop(){
     this.ctrmusic.stop();
  }
  private createBitmapByName(name: string): egret.Bitmap {
        let result = new egret.Bitmap();
        let texture: egret.Texture = RES.getRes(name);
        result.texture = texture;
        return result;
    }
}